<?php
namespace App\Http\Controllers\Admin;

use App\Service\Admin\PointService;
use Illuminate\Http\Request;

class PointController extends BaseController
{
    //二期积分

    public function __construct(PointService $service)
    {
        $this->db = $service;
    }

    //列表
    public function getList(Request $request)
    {
        $type = $request->post('type', 0);
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->getList($type, $pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //兑换的
    public function orderList(Request $request)
    {
        $pages['start'] = $request->post('start', 1);
        $pages['limit'] = $request->post('limit', 10);
        $res = $this->db->orderList($pages);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson(0, '', $res['data'], $res['total']);
    }

    //审核
    public function auth(Request $request)
    {
        $id = $request->post('id', 0);
        $res = $this->db->auth($id);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }

    //发货
    public function send(Request $request)
    {
        $id = $request->post('id', 0);
        $pas['wuliu'] = $request->post('wuliu', '');
        $pas['wuliuhao'] = $request->post('wuliuhao', '');
        $res = $this->db->send($id, $pas);
        if ($res['code'] < 0) {
            return $this->toJson(-2, $res['msg']);
        }
        return $this->toJson();
    }
}